﻿Public Class RinstanciaTP

    Public Shared Function SeleccionarTodo(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean) As List(Of EinstanciasTP)
        Dim tinstanciaTP As List(Of EinstanciasTP) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                tinstanciaTP = DinstanciaTP.SeleccionarTodo(descEmpresa)
                If tinstanciaTP Is Nothing Then tinstanciaTP = New List(Of EinstanciasTP)
                If DisplaySelect Then tinstanciaTP.Insert(0, New EinstanciasTP("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return tinstanciaTP
    End Function
    Public Shared Function SeleccionarXEstado(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean) As List(Of EtpoConstruccion)
        Dim contruccions As List(Of EtpoConstruccion) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                contruccions = DTpoConstruccion.SeleccionarTodoxEstado(descEmpresa)
                If contruccions Is Nothing Then contruccions = New List(Of EtpoConstruccion)
                If DisplaySelect Then contruccions.Insert(0, New EtpoConstruccion("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return contruccions
    End Function
    Public Shared Function Añadir(ByVal descEmpresa As String, ByVal pinstanciaTP As EinstanciasTP) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DinstanciaTP.Añadir(descEmpresa, pinstanciaTP)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function Editar(ByVal descEmpresa As String, ByVal pinstanciaTP As EinstanciasTP) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DinstanciaTP.Editar(descEmpresa, pinstanciaTP)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function Eliminar(ByVal descEmpresa As String, ByVal pinstanciaTP As EinstanciasTP) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DinstanciaTP.Eliminar(descEmpresa, pinstanciaTP)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function

End Class
